<?php
namespace App\Http\Controllers\Admin;
use Illuminate\Http\Request;
class UserController extends \App\Http\Controllers\AdminController{
    //put your code here
    public function index() {
        $users = \App\Models\User::paginate();
        $countuser = \App\Models\User::count();
        $assign = compact("users", 'countuser');
        return view('admin.user.index', $assign);
    }
     /**
     * 修改用户确认信息
     * @param Request $request
     * @param type $id
     * @param type $status
     * @return type
     */
    public function edit(Request $request, $id, $status) {
        $res = \App\Models\User::where("id", $id)->update(['isver'=> $status]);
        if ($res) {
            $info = ['status'=> 1, 'info'=>"确认信息成功"];
        } else {
            $info = ['status'=> 0, 'info'=>"确认信息失败"];
        }
        return \Illuminate\Support\Facades\Response::json($info);
    }
    /**
     * 修改用户确认信息
     * @param Request $request
     * @param type $id
     * @param type $status
     * @return type
     */
    public function editzw(Request $request, $id, $status) {
        $res = \App\Models\User::where("id", $id)->update(['isinsp'=> $status]);
        if ($res) {
            $info = ['status'=> 1, 'info'=>"设置成功"];
        } else {
            $info = ['status'=> 0, 'info'=>"设置失败"];
        }
        return \Illuminate\Support\Facades\Response::json($info);
    }
    /**
     * 删除用户
     */
    public function delUser($id) {
        $res = $res = \App\Models\User::where("id", $id)->delete();
        if ($res) {
            $info = ['status'=> 1, 'info'=>"删除信息成功"];
        } else {
            $info = ['status'=> 0, 'info'=>"删除信息失败"];
        }
        return \Illuminate\Support\Facades\Response::json($info);
    }
}
